home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / Demos / Herois / Codigo.Cst / 00028_Script_Fundo Sonoro Aleatorio < prev    next >
Text File  |  1999-03-19  |  2KB  |  75 lines

  1. property memSomPrim, memSomUlt, memPrim, memQuantos
  2. property ligado
  3. property tempoIn
  4. property minTocando, maxTocando
  5. property 
  6.  
  7. on getBehaviorDescription
  8.   return "Faz busca automatica de palavra clicada"
  9. end
  10.  
  11. on getPropertyDescriptionList
  12.   set p_list = [ ¼
  13.     #memSomPrim: [ #comment:   "Primeiro membro que contem som",¼
  14.                  #format:   #string, ¼
  15.                  #default:    "MembroSom" ],¼
  16.     #memSomUlt: [ #comment:   "Ultimo membro que contem som",¼
  17.                  #format:   #string, ¼
  18.                  #default:    "MembroSom" ],¼
  19.     #tempoIn: [ #comment:   "Tempo de fadeIn",¼
  20.                  #format:   #integer, ¼
  21.                  #default:  120 ],¼
  22.     #minTocando: [ #comment:   "Tempo minimo que o som fica tocando",¼
  23.                  #format:   #integer, ¼
  24.                  #default:     300],¼
  25.     #maxTocando: [ #comment:   "Tempo maximo que o som fica tocando",¼
  26.                  #format:   #integer, ¼
  27.                  #default:  800 ]¼
  28.   ]
  29.   return p_list
  30. end
  31.  
  32. on beginSprite me
  33.   set ligado = false
  34.   set memPrim = the number of member memSomPrim
  35.   set memQuantos = (the number of member memSomUlt) - memPrim + 1
  36. end
  37.  
  38. on cleanSprite me
  39.   if ligado then
  40.     global gFundoTempo
  41.     sound fadeOut 1, tempoIn
  42.     set gFundoTempo = the timer + tempoIn + 30
  43.     set ligado = false
  44.   end if
  45. end
  46.  
  47. on idleSprite me
  48.   global gMustUpdate
  49.   global gFundoTempo  
  50.   if ligado then
  51.     if the timer >= gFundoTempo then
  52.       if soundBusy(1) then sound fadeOut 1, tempoIn
  53.       set gMustUpdate to true
  54.       set ligado = false
  55.       set gFundoTempo = the timer + tempoIn + random(maxTocando - minTocando) + minTocando
  56.     end if
  57.     
  58.   else -- Som desligado, espera o tempo para religar
  59.     if the timer >= gFundoTempo then
  60.       puppetSound 1, 0
  61.       updateStage
  62.       set the volume of sound 1 to 255
  63.       updateStage
  64.       set gMustUpdate to true
  65.       if memPrim >= 0 then
  66.         --set num_mem = (memPrim + random(memQuantos) - 1)
  67.         set num_mem = memPrim
  68.         puppetSound 1, num_mem
  69.       end if
  70.       sound fadeIn 1, tempoIn
  71.       set ligado = true
  72.       set gFundoTempo = the timer + random(maxTocando - minTocando) + minTocando
  73.     end if
  74.   end if
  75. end